from django import forms
from .models import *

class ArticleForm(forms.Form):
    title=forms.CharField(
        label='标题',
        max_length=30,
        min_length=2,
        error_messages={
            "min_length":"长度小于2",
            "max_length":"长度大于30",

        }
    )
    desc=forms.CharField(
        label="副标题",
        max_length=60,
        min_length=2,
        error_messages={
            "min_length": "长度小于2",
            "max_length": "长度大于60",

        }
    )
    content=forms.CharField(
        label="文章内容",
        widget=forms.Textarea
    )
    cover=forms.FileField(
        label='封面图'
    )
    classes=forms.ModelChoiceField(
        label='分类',
        queryset=Classes.objects.all(),
        empty_label=None
    )
    label=forms.ModelMultipleChoiceField(
        label="标签",
        queryset=Label.objects.all()
    )